package com.unipay.msm.receiver;

import com.rabbitmq.client.Channel;
import com.unipay.common.rabbit.constant.MqConst;
import com.unipay.msm.service.MsmService;
import com.unipay.vo.msm.MsmVo;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author Chenmy
 * @Date 2023/7/9 18:31
 * @Desc TODO   封装mq监听器
 */
@Component
public class SmsReceiver {
    @Autowired
    private MsmService msmService;

    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(value = MqConst.QUEUE_MSM_ITEM, durable = "true"),
                    exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_MSM),
                    key = {MqConst.ROUTING_MSM_ITEM}
            )
    )
    public void send(MsmVo msmVo, Message message, Channel channel){
        msmService.send(msmVo);
    }
}
